/*
 * CodeDict.h
 *
 *  Created on: 2022-01-08
 *      Author: chuanjiang.zh
 */

#ifndef CODEDICT_H_
#define CODEDICT_H_

#include "BasicType.h"
#include <string>
#include <map>
#include <mutex>

class CodeDict
{

public:
    typedef std::map< int, std::string> Map;

    static bool load(const std::string& filepath, const std::string& section, Map& wordMap);

public:
    CodeDict();
    virtual ~CodeDict();

    bool load(const std::string& filepath, const std::string& sectionName);

    bool find(int key, std::string& value);

    std::string get(int key, const char* defValue = "");

    void clear();

    size_t size();

    bool exists(int key);

    void put(int key, const std::string& value);

protected:

protected:
    Map   m_map;
    std::mutex  m_mutex;

};

#endif /* CODEDICT_H_ */
